matplotlib increase tick frequency

41

start, end = ax.get_xlim()
ax.xaxis.set_ticks(np.arange(start, end, stepsize))
# credit ot the Stack Overflow user in the source link
# this is just an example in which you increase the number of ticks on the x-axis
# that is, the spacing between consecutive plotted ticks is reduced 

import numpy as np
import matplotlib.pyplot as plt

x = [0,5,9,10,15]
y = [0,1,2,3,4]

plt.plot(x,y)
plt.xticks(np.arange(min(x), max(x)+1, 1.0))
plt.show()

Comments

Submit
0 Comments